from flask import jsonify

def success_response(message='操作成功', data=None, pagination=None):
    """
    统一的成功响应格式
    
    Args:
        message: 响应消息
        data: 响应数据
        pagination: 分页信息（可选）
    
    Returns:
        Flask JSON响应对象
    """
    response = {
        'status': 'success',
        'message': message
    }
    
    if data is not None:
        response['data'] = data
    
    if pagination is not None:
        response['pagination'] = pagination
    
    return jsonify(response), 200

def error_response(message='操作失败', error=None, status_code=500):
    """
    统一的错误响应格式
    
    Args:
        message: 错误消息
        error: 错误详情（可选）
        status_code: HTTP状态码
    
    Returns:
        Flask JSON响应对象
    """
    response = {
        'status': 'error',
        'message': message
    }
    
    if error is not None:
        response['error'] = error
    
    return jsonify(response), status_code